package com.down.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SelJdbc {

	public List<Map<String,Object>> selectMuls() {
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Connection conn = JDBCHelper.getConn();
		PreparedStatement prepStmt = null;
		ResultSet rs = null;
		String sql = "SELECT `urlId`, `text`, `username` FROM `t_instagram` LIMIT 100";
		try {

			prepStmt = conn.prepareStatement(sql);
			rs = prepStmt.executeQuery();
			while(rs.next()){
				Map<String,Object> temp = new HashMap<String,Object>();
				temp.put("urlId", rs.getLong("urlId"));
				temp.put("text", rs.getString("text"));
				temp.put("username", rs.getString("username"));
				list.add(temp);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JDBCHelper.closeAll(rs, prepStmt, conn);
		}
		return list;
	}
}
